package com.app.service.impl;

import com.app.mapper.TaskMapper;
import com.app.model.TaskModel;
import com.app.service.TaskService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TaskServiceImpl implements TaskService {
    @Autowired
    private TaskMapper taskMapper;

    @Override
    public IPage<TaskModel> selectTaskList(String name, Integer page, Integer limit, Integer departmentId, Integer sortType) {
        Page<TaskModel> p = new Page<>(page,limit);
        return taskMapper.selectTaskList(p,departmentId,name,sortType);
    }

    @Override
    public void update(TaskModel taskModel) {
        taskMapper.updateById(taskModel);
    }

    @Override
    public void insert(TaskModel taskModel) {
        taskMapper.insert(taskModel);
    }

    @Override
    public void delete(Integer id) {
        taskMapper.deleteById(id);
    }

    @Override
    public List<TaskModel> selectAll(Integer departmentId) {
        return taskMapper.getList(departmentId);
    }
}
